<template>
  <div class="tabbaritem" @click="itemclick">
    <div v-if="isActive"><slot name="itemicon"></slot></div>
    <div v-else><slot name="itemiconactive"></slot></div>
    <div  :style="activestyle"><slot name="itemtext"></slot></div>
  </div>
</template>

<script>
export default {
  name: "tabbaritem",
  props:{
    path:String,
    activecolor: {
      default:'red',
      type:String
    }
  },
  data(){
    return{
      // isActive: true
    }
  },
  computed:{
    isActive(){
      return this.$route.path.indexOf(this.path)
    },
    activestyle(){
      return this.isActive ? {} : {color: this.activecolor}
    }
  },
  methods:{
    itemclick(){
      this.$router.replace(this.path)
    }
  }
}
</script>

<style scoped>
.tabbaritem{
  flex: 1;
  text-align: center;
  height: 49px;
  font-size: 14px;
}
.tabbaritem img{
  width: 24px;
  height: 24px;
  margin-top: 3px;
  vertical-align: middle;
  margin-bottom: 2px;
}
/*.active{*/
/*  color: red;*/
/*}*/
</style>
